package com.nanrui.mutualinductor.ui.service;

import com.nanrui.mutualinductor.communicate.PacketCallback;
import com.nanrui.mutualinductor.data.Packet_57;
import com.nanrui.mutualinductor.domains.VoltageTransformerViewInfo;
import com.nanrui.mutualinductor.ui.page.DKActivity;


public class VoltageTransformerService
{
    private DKActivity activity;

    public VoltageTransformerService(DKActivity paramDKActivity)
    {
        this.activity = paramDKActivity;
    }

    public void display(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, Packet_57 paramPacket_57)
    {
        //tab1
        paramVoltageTransformerViewInfo.setsPhaseError(Float.valueOf(paramPacket_57.getsPhaseError()));
        paramVoltageTransformerViewInfo.setsQuadratureError(Float.valueOf(paramPacket_57.getsQuadratureError()));
        paramVoltageTransformerViewInfo.setsPrimaryU(Float.valueOf(paramPacket_57.getsWorkingVoltage()));
        paramVoltageTransformerViewInfo.setsSecondaryR(Float.valueOf(paramPacket_57.getsSecondaryR()));
        paramVoltageTransformerViewInfo.setsDCR(Float.valueOf(paramPacket_57.getsDCR()));
        paramVoltageTransformerViewInfo.setsXb(Float.valueOf(paramPacket_57.getsXb()));

        paramVoltageTransformerViewInfo.setsFErrors(paramPacket_57.getsFErrors());
        paramVoltageTransformerViewInfo.setsDErrors(paramPacket_57.getsDErrors());

        //tab2
        paramVoltageTransformerViewInfo.setsG(Float.valueOf(paramPacket_57.getsPhaseError()));
        paramVoltageTransformerViewInfo.setsB(Float.valueOf(paramPacket_57.getsQuadratureError()));
        paramVoltageTransformerViewInfo.setsSecondaryU(Float.valueOf(paramPacket_57.getsWorkingVoltage()));

        paramVoltageTransformerViewInfo.setsUErrors(paramPacket_57.getsUErrors());
        paramVoltageTransformerViewInfo.setsURoundErrors(paramPacket_57.getsURoundErrors());
        paramVoltageTransformerViewInfo.setsPhaseDisps(paramPacket_57.getsPhaseDisps());
        paramVoltageTransformerViewInfo.setsPhaseRoundDisps(paramPacket_57.getsPhaseRoundDisps());
    }

    public VoltageTransformerViewInfo getDefaultViewInfo()
    {
        VoltageTransformerViewInfo localVoltageTransformerViewInfo = new VoltageTransformerViewInfo();
        localVoltageTransformerViewInfo.setmStatus((short)1);

//        localVoltageTransformerViewInfo.setmRatedSecondary(DKPowerData.PT_2ND_VOLTAGE_RADICAL_100);
//        localVoltageTransformerViewInfo.setmRatedPrimary(6.0F);
//        localVoltageTransformerViewInfo.setmGrade((short)1);
//        localVoltageTransformerViewInfo.setmPhaseAngle(0.8F);
//        localVoltageTransformerViewInfo.setmMeaWinRatedLoad(150.0F);
//        localVoltageTransformerViewInfo.setmMeaWinMiniLoad(37.5F);
//        localVoltageTransformerViewInfo.setmSurWinRatedLoad(0.0F);
//        localVoltageTransformerViewInfo.setmSurWinMiniLoad(0.0F);
        return localVoltageTransformerViewInfo;
    }

    public void queryData(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, PacketCallback<Packet_57> paramPacketCallback)
    {
        Packet_57 localPacket_57 = new Packet_57();
        localPacket_57.setmFlag((short)3);
        localPacket_57.setFrameNo((short) 02);
        localPacket_57.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
        localPacket_57.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
        localPacket_57.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
        localPacket_57.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57.setmPhaseAngle(paramVoltageTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57, paramPacketCallback);
    }

    public void resetResult(VoltageTransformerViewInfo paramVoltageTransformerViewInfo)
    {
        paramVoltageTransformerViewInfo.setsPhaseError(null);
        paramVoltageTransformerViewInfo.setsQuadratureError(null);
        paramVoltageTransformerViewInfo.setsPrimaryU(null);
        paramVoltageTransformerViewInfo.setsSecondaryR(null);
        paramVoltageTransformerViewInfo.setsDCR(null);
        paramVoltageTransformerViewInfo.setsXb(null);
        paramVoltageTransformerViewInfo.setsFErrors(null);
        paramVoltageTransformerViewInfo.setsDErrors(null);
        paramVoltageTransformerViewInfo.setsG(null);
        paramVoltageTransformerViewInfo.setsB(null);
        paramVoltageTransformerViewInfo.setsSecondaryU(null);
        paramVoltageTransformerViewInfo.setsUErrors(null);
        paramVoltageTransformerViewInfo.setsURoundErrors(null);
        paramVoltageTransformerViewInfo.setsPhaseDisps(null);
        paramVoltageTransformerViewInfo.setsPhaseRoundDisps(null);
        paramVoltageTransformerViewInfo.setsResult(null);
    }

//    public PTErrorResp save(VoltageTransformerViewInfo paramVoltageTransformerViewInfo)
//    {
//        PTErrorResp localPTErrorResp = new PTErrorResp();
//        localPTErrorResp.setsPhaseError(paramVoltageTransformerViewInfo.getsPhaseError());
//        localPTErrorResp.setsQuadratureError(paramVoltageTransformerViewInfo.getsQuadratureError());
//        localPTErrorResp.setsPrimaryU(paramVoltageTransformerViewInfo.getsPrimaryU());
//        localPTErrorResp.setsSecondaryR(paramVoltageTransformerViewInfo.getsSecondaryR());
//        localPTErrorResp.setsDCR(paramVoltageTransformerViewInfo.getsDCR());
//        localPTErrorResp.setsXb(paramVoltageTransformerViewInfo.getsXb());
//        localPTErrorResp.setsNoLoadRatioErr(Float.valueOf(paramVoltageTransformerViewInfo.getsFErrors()[0]));
//        localPTErrorResp.setsNoLoadAngleErr(Float.valueOf(paramVoltageTransformerViewInfo.getsDErrors()[0]));
//        localPTErrorResp.setsFullLoadRatioErr(Float.valueOf(paramVoltageTransformerViewInfo.getsFErrors()[1]));
//        localPTErrorResp.setsFullLoadAngleErr(Float.valueOf(paramVoltageTransformerViewInfo.getsDErrors()[1]));
//        localPTErrorResp.setsLightLoadRatioErr(Float.valueOf(paramVoltageTransformerViewInfo.getsFErrors()[2]));
//        localPTErrorResp.setsLightLoadAngleErr(Float.valueOf(paramVoltageTransformerViewInfo.getsDErrors()[2]));
//        localPTErrorResp.setsG(paramVoltageTransformerViewInfo.getsG());
//        localPTErrorResp.setsB(paramVoltageTransformerViewInfo.getsB());
//        localPTErrorResp.setsSecondaryU(paramVoltageTransformerViewInfo.getsSecondaryU());
//        localPTErrorResp.setsUErrors(paramVoltageTransformerViewInfo.getsUErrors());
//        localPTErrorResp.setsURoundErrors(paramVoltageTransformerViewInfo.getsURoundErrors());
//        localPTErrorResp.setsPhaseDisps(paramVoltageTransformerViewInfo.getsPhaseDisps());
//        localPTErrorResp.setsPhaseRoundDisps(paramVoltageTransformerViewInfo.getsPhaseRoundDisps());
//        localPTErrorResp.setsResult(paramVoltageTransformerViewInfo.getsResult().shortValue());
//        localPTErrorResp.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
//        localPTErrorResp.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
//        localPTErrorResp.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
//        localPTErrorResp.setmCos(paramVoltageTransformerViewInfo.getmPhaseAngle());
//        localPTErrorResp.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
//        localPTErrorResp.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
//        localPTErrorResp.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
//        localPTErrorResp.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
//        localPTErrorResp.setmTemp(Float.valueOf(0.0F));
//        localPTErrorResp.setmRH(Float.valueOf(0.0F));
//        localPTErrorResp.setmCreateDate(System.currentTimeMillis());
//        return localPTErrorResp;
//    }

    public void start1ndMeasure(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, PacketCallback<Packet_57> paramPacketCallback)
    {
        Packet_57 localPacket_57 = new Packet_57();
        localPacket_57.setmFlag((short)1);
        localPacket_57.setFrameNo((short) 02);
        localPacket_57.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
        localPacket_57.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
        localPacket_57.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
        localPacket_57.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57.setmPhaseAngle(paramVoltageTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57, paramPacketCallback);
    }

    public void start2ndMeasure(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, PacketCallback<Packet_57> paramPacketCallback)
    {
        Packet_57 localPacket_57 = new Packet_57();
        localPacket_57.setmFlag((short)2);
        localPacket_57.setFrameNo((short) 02);
        localPacket_57.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
        localPacket_57.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
        localPacket_57.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
        localPacket_57.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57.setmPhaseAngle(paramVoltageTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57, paramPacketCallback);
    }

    public void stopMeasure(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, PacketCallback<Packet_57> paramPacketCallback)
    {
        Packet_57 localPacket_57 = new Packet_57();
        localPacket_57.setmFlag((short)4);
        localPacket_57.setFrameNo((short) 02);
        localPacket_57.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
        localPacket_57.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
        localPacket_57.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
        localPacket_57.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57.setmPhaseAngle(paramVoltageTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57, paramPacketCallback);
    }

    public void updateConfig(VoltageTransformerViewInfo paramVoltageTransformerViewInfo, PacketCallback<Packet_57> paramPacketCallback)
    {
        Packet_57 localPacket_57 = new Packet_57();
        localPacket_57.setmFlag((short)0);
        localPacket_57.setFrameNo((short) 02);
        localPacket_57.setmGrade(paramVoltageTransformerViewInfo.getmGrade());
        localPacket_57.setmRatedPrimary(paramVoltageTransformerViewInfo.getmRatedPrimary());
        localPacket_57.setmRatedSecondary(paramVoltageTransformerViewInfo.getmRatedSecondary());
        localPacket_57.setmMeaWinRatedLoad(paramVoltageTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57.setmMeaWinMiniLoad(paramVoltageTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57.setmSurWinRatedLoad(paramVoltageTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57.setmSurWinMiniLoad(paramVoltageTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57.setmPhaseAngle(paramVoltageTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57, paramPacketCallback);
    }
}

